#include "Node.h"

//#include "Entity3d.h"
using namespace ns;


Node::Node()
{
	countChilds = 0;
} // Constructor

/*Node::~Node(void)
{
    m_Children.clear();
} // Destructor*/


void Node::AddChildNode(Entity3d* ChildNode)
{
	
    if(NULL != ChildNode)
    {
		ChildNode->SetParent(this);   
		children[countChilds] = ChildNode;
		countChilds++;
    }
}; // AddChildNode()

void Node::RemoveChildNode(Entity3d* ChildNode)
{
    if(NULL != ChildNode && countChilds != 0 )
    {
        for(int i = 0; i < countChilds; ++i)
        {
            if(children[i] == ChildNode)
            {
				delete children[i];
				children[i] = NULL;
                break; // break the for loop
            }
        }
    }
}; // RemoveChildNode()

const char* Node::GetNodeName(void) const
{
    return(m_Name);
}; // GetNodeName()

void Node::Draw(){
	for(int i = 0;i<countChilds;i++){
		if(children[i]!=NULL){
			children[i]->Draw();
		}
	}
}


void Node::UpdateTransformation() {
	Entity3d::UpdateTransformation();
	for( int i = 0;i<countChilds;i++)
	{
		if (children[i] != NULL)
			children[i]->UpdateTransformation();
	}
}
